package service

import (
	"context"
	"go.opentelemetry.io/otel"

	"github.com/cloudwego/hertz/pkg/app"
	user "userapi/hertz_gen/user"
	rpcmodel "userrpc/kitex_gen/user"
	"userrpc/rpc"
)

type LogoutService struct {
	RequestContext *app.RequestContext
	Context        context.Context
}

func NewLogoutService(Context context.Context, RequestContext *app.RequestContext) *LogoutService {
	return &LogoutService{RequestContext: RequestContext, Context: Context}
}

func (h *LogoutService) Run(req *user.User) (resp *user.Response, err error) {
	//defer func() {
	// hlog.CtxInfof(h.Context, "req = %+v", req)
	// hlog.CtxInfof(h.Context, "resp = %+v", resp)
	//}()
	// todo edit your code
	spanCtx, span := otel.Tracer("loginout").Start(h.Context, "loginoutRpc")
	r, err := rpc.Client().Logout(spanCtx, &rpcmodel.User{})
	span.End()
	resp = &user.Response{
		Message: r.Message,
	}
	return
}
